<template>
  <j-modal
    :width="modalWidth"
    :visible="visible"
    :title="title"
    switchFullscreen
    @ok="handleSubmit"
    @cancel="close"
    style="top:50px"
    cancelText="关闭">
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    
    <!-- 操作按钮区域 -->
    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        class="j-table-force-nowrap"
        :scroll="{x:true}"
        :columns="columns"
        :dataSource="mappeddDataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange,type:'radio'}"
        @change="handleTableChange">
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

<!--        <span slot="action" slot-scope="text, record">-->
<!--          <a @click="handleEdit(record)">编辑</a>-->

<!--          <a-divider type="vertical" />-->
<!--          <a-dropdown>-->
<!--            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>-->
<!--            <a-menu slot="overlay">-->
<!--              <a-menu-item>-->
<!--                <a @click="handleDetail(record)">详情</a>-->
<!--              </a-menu-item>-->
<!--              <a-menu-item>-->
<!--                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">-->
<!--                  <a>删除</a>-->
<!--                </a-popconfirm>-->
<!--              </a-menu-item>-->
<!--            </a-menu>-->
<!--          </a-dropdown>-->
<!--        </span>-->

      </a-table>
    </div>

  </a-card>
  </j-modal>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import '@/assets/less/TableExpand.less'
  // import { getDictItems } from '@comp/dict/JDictSelectUtil'
  import { filterMultiDictText,getDictItems } from '@/components/dict/JDictSelectUtil'


  export default {
    name: "BussStorageNoticeList",
    mixins:[JeecgListMixin],
    components: {

    },
    props: {
      category: {
        type: String
      },
      modalWidth: {
        type: Number,
        required: false,
        default: 1250
      },
      checkval: {
        type: String,
        default: 'radio'
      },
      supplierId: {
        type: String,
        required: false
      }
    },
    data () {
      return {
        visible: false,
        title: '选择入库通知单',
        dict:{
          rkType: [],
          unit: []
        },
        description: '入库通知单管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'编号',
            align:"center",
            dataIndex: 'code'
          },
          {
            title:'单据类型',
            align:"center",
            dataIndex: 'type_dictText'
          },
          {
            title:'供应商',
            align:"center",
            dataIndex: 'supplierName'
          },
          {
            title:'批次号',
            align:"center",
            dataIndex: 'lotNumber'
          },
          {
            title:'质检单编号-',
            align:"center",
            dataIndex: ''
          },
          {
            title:'质检结果-',
            align:"center",
            dataIndex: ''
          },
          {
            title:'质检数量-',
            align:"center",
            dataIndex: ''
          },
          {
            title:'原料编号',
            align:"center",
            dataIndex: 'materialCode'
          },
          {
            title:'原料名称',
            align:"center",
            dataIndex: 'materialName'
          },
          {
            title:'规格',
            align:"center",
            dataIndex: 'spec'
          },
          {
            title:'单位',
            align:"center",
            dataIndex: 'unit_dict'
          },
          {
            title:'采购数量',
            align:"center",
            dataIndex: 'procurementNum'
          },
          {
            title:'原发数',
            align:"center",
            dataIndex: 'originalNum'
          },
          {
            title:'实收数量',
            align:"center",
            dataIndex: 'actualNum'
          },
          {
            title:'制单日期',
            align:"center",
            dataIndex: 'createTime'
          },
          {
            title:'制单人',
            align:"center",
            dataIndex: 'createBy'
          },
          {
            title:'进厂日期',
            align:"center",
            dataIndex: 'factoryTime'
          },
          {
            title:'生产日期',
            align:"center",
            dataIndex: 'createDate'
          },
          {
            title:'限用日期',
            align:"center",
            dataIndex: 'expiryDate'
          },
          {
            title:'让步接受数量-',
            align:"center",
            dataIndex: ''
          },
          {
            title:'入库数量-',
            align:"center",
            dataIndex: ''
          },
          {
            title:'物料批号',
            align:"center",
            dataIndex: 'materialLotNum'
          },
          {
            title:'库位',
            align:"center",
            dataIndex: 'storehouse'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' },
          }
        ],
        url: {
          list: "/business/bussStorageNotice/list",
          delete: "/business/bussStorageNotice/delete",
          deleteBatch: "/business/bussStorageNotice/deleteBatch",
          exportXlsUrl: "/business/bussStorageNotice/exportXls",
          importExcelUrl: "business/bussStorageNotice/importExcel",
          
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
      this.getSuperFieldList();
      // getDictItems('rk_type').then(res=>{
      //   this.dict.rkType = res
      // });
      // getDictItems('zl_unit').then(res=>{
      //   this.dict.unit = res
      // });
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
      mappeddDataSource(){
        return this.dataSource.map(data => ({
          ...data,
          // type_dictText: this.dict.rkType[data.type].label,
          // unit_dict: this.dict.unit[data.type].label
          // statusText: statusDict[data.status]
        }));
      }
    },
    methods: {
      close() {
        // this.searchReset(false);
        this.queryParam = {}
        this.selectedRowKeys = []
        this.selectionRows = []
        this.visible = false;
        this.visible = false;
      },
      handleSubmit() {
        this.getGoodsSelectRows();
        this.searchReset(false)
        this.onClearSelected();
        this.close();
      },
      add() {
        this.showModal();
      },
      showModal() {
        this.dataSource = []
        this.visible = true;
        this.loadData();
      },
      getGoodsSelectRows() {
        let selectedRow = null;
        selectedRow = this.selectionRows[0]
        //传递选中的数据
        this.$emit("handlerOk", selectedRow);
      },
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'code',text:'单据编号',dictCode:''})
        fieldList.push({type:'string',value:'type',text:'单据类型',dictCode:''})
        fieldList.push({type:'string',value:'lotNumber',text:'批次号',dictCode:''})
        fieldList.push({type:'datetime',value:'factoryTime',text:'进场日期'})
        fieldList.push({type:'string',value:'venderId',text:'供应商',dictCode:''})
        fieldList.push({type:'string',value:'procurementId',text:'采购id',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>